package core.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import core.dao.*;

/**
 * @author Mario Romero
 *
 *Informacion sobre clase:
 *esta clase tiene los metodos de la interfaz GenericDao implementados
 */

/**
 * This class serves as the Base class for all other DAOs - namely to hold
 * common CRUD methods that they might all use. You should only need to extend
 * this class when your require custom CRUD logic.
 * <p/>
 * <p>
 * To register this class in your Spring context file, use the following XML.
 * 
 * <pre>
 *      &lt;bean id="fooDao" class="es.dm.dao.hibernate.GenericDaoHibernate"&gt;
 *          &lt;constructor-arg value="es.dm.model.Foo"/&gt;
 *      &lt;/bean&gt;
 * </pre>
 * 
 * @author <a href="mailto:bwnoll@gmail.com">Bryan Noll</a>
 * @param <T>
 *            a type variable
 * @param <PK>
 *            the primary key for that type
 */
public class GenericDaoImpl<T, PK extends Serializable> implements
		GenericDao<T, PK> {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<T> getAll() {
		return null;
		// return hibernateTemplate.loadAll(this.persistentClass);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<T> getAllDistinct() {

		return null;

		// Collection result = new LinkedHashSet(getAll());
		// return new ArrayList(result);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public T get(PK id) {
		return null;

		// T entity = (T) hibernateTemplate.get(this.persistentClass, id);
		//
		// if (entity == null) {
		// log.warn("Uh oh, '" + this.persistentClass + "' object with id '" +
		// id + "' not found...");
		// throw new ObjectRetrievalFailureException(this.persistentClass, id);
		// }
		//
		// return entity;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean exists(PK id) {
		return false;
		// T entity = (T) hibernateTemplate.get(this.persistentClass, id);
		// return entity != null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public T save(T object) {
		return null;
		// return (T) hibernateTemplate.merge(object);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void remove(PK id) {
		// hibernateTemplate.delete(this.get(id));
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<T> findByNamedQuery(String queryName,
			Map<String, Object> queryParams) {

		return null;

		// String[] params = new String[queryParams.size()];
		// Object[] values = new Object[queryParams.size()];
		//
		// int index = 0;
		// for (String s : queryParams.keySet()) {
		// params[index] = s;
		// values[index++] = queryParams.get(s);
		// }
		//
		// return hibernateTemplate.findByNamedQueryAndNamedParam(queryName,
		// params, values);
	}

}
